# uncompyle6 version 3.2.3
# Python bytecode 3.6 (3379)
# Decompiled from: Python 3.6.8 |Anaconda custom (64-bit)| (default, Feb 21 2019, 18:30:04) [MSC v.1916 64 bit (AMD64)]
# Embedded file name: helpers\emails\__init__.py
__author__ = "Attila Gerendi (Sanyi)"
import os.path

_banned_email_domain_list = set()
_grey_email_domain_list = set()
_path = os.path.dirname(__file__)


def get_grey_email_domain_list():
    if not _grey_email_domain_list:
        for domain in open(
            os.path.join(_path, "domains", "grey.txt"), "rt"
        ).readlines():
            _grey_email_domain_list.add(domain.strip())

    return _grey_email_domain_list


def get_banned_email_domain_list():
    global _banned_email_domain_list
    if not _banned_email_domain_list:
        for domain in open(
            os.path.join(_path, "domains", "free.txt"), "rt"
        ).readlines():
            _banned_email_domain_list.add(domain.strip())

        for domain in open(
            os.path.join(_path, "domains", "throwaway.txt"), "rt"
        ).readlines():
            _banned_email_domain_list.add(domain.strip())

        for domain in open(
            os.path.join(_path, "domains", "banned.txt"), "rt"
        ).readlines():
            _banned_email_domain_list.add(domain.strip())

    return _banned_email_domain_list


def is_email_banned(email):
    _, domain = email.lower().split("@")
    if domain in get_grey_email_domain_list():
        return False
    else:
        return domain in get_banned_email_domain_list() or domain.endswith(".tk")


def is_email_untrusted(email):
    _, domain = email.lower().split("@")
    return domain in get_grey_email_domain_list()
